#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;


int a[110];

int Max,Min;
int main(){
    Min = Max = 0;
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        if(a[i]>a[Max]) Max = i;
        if(a[i]<a[Min]) Min = i;
    }
    int ans = 0;
    ans = max(ans,Min);
    ans = max(ans,Max);
    ans = max(ans,n-1-Min);
    ans = max(ans,n-1-Max);
    cout << ans << endl;
    return 0;
}
